<template>
  <view v-if="visible" class="loading-wrapper">
    <view class="loading-spinner"></view>
  </view>
</template>

<script setup>
import { ref, defineProps, watch } from 'vue'

// 定义组件的属性
const props = defineProps({
  visible: {
    type: Boolean,
    default: false // 控制加载动画是否显示
  }
})

// 监听属性变化
watch(
  () => props.visible,
  (newVal) => {
    console.log('Loading state:', newVal)
  }
)
</script>

<style scoped>
.loading-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
